package com.offcn;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class Insert {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //1）加载驱动
        Class.forName("com.mysql.jdbc.Driver");
        // 2）创建连接
        Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/myschool", "root", "root");
        // 3）创建SQL执行平台
        Statement stmt = conn.createStatement();
        // 4）执行SQL语句
        int num = stmt.executeUpdate("insert into accou values(3,1000)");
        //5）处理结果
        if(num>0){
            System.out.println("添加成功");
        }else{
            System.out.println("添加失败");
        }
        // 6）释放资源

        stmt.close();
        conn.close();
    }
}
